主题
加密模型包到内存 - YoloEncryptModelEx
函数简介
加密并输出整包到内存。
接口名称
YoloEncryptModelExDLL 调用
int YoloEncryptModelEx(long ola, long modelData, int modelSize, long ncnnParamData, int ncnnParamSize, long labelData, int labelSize, string password, int modelType, int inferenceType, long* outPackageData, long* outPackageSize);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| ola | 长整数型 | OLAPlug 对象指针,由 CreateCOLAPlugInterFace 生成。 |
| modelData | 长整数型 | 主模型地址。 |
| modelSize | 整数型 | 主模型长度。 |
| ncnnParamData | 长整数型 | NCNN param 地址。 |
| ncnnParamSize | 整数型 | param 长度。 |
| labelData | 长整数型 | 类别名称表内存地址;无则 0。原始字节,编码见 类别名称表说明。 |
| labelSize | 整数型 | 类别名称表字节长度;无则 0。 |
| password | 字符串 | 密码。 |
| modelType | 整数型 | 模型类型。 |
| inferenceType | 整数型 | 推理类型。 |
| outPackageData | 长整数型* | 输出:整包地址。 |
| outPackageSize | 长整数型* | 输出:包总长度。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
int ret = ola.YoloEncryptModelEx(0, 0, "models/yolov8n.olam", "models/yolov8n.olam", 0, 0, "your_password", 0, 0, "value", "value");csharp
using OLAPlug;
var ola = new OLAPlugServer();
int ret = ola.YoloEncryptModelEx(0, 0, "models/yolov8n.olam", "models/yolov8n.olam", 0, 0, "your_password", 0, 0, "value", "value");python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
ret = ola.YoloEncryptModelEx(0, 0, "models/yolov8n.olam", "models/yolov8n.olam", 0, 0, "your_password", 0, 0, "value", "value")java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
int ret = ola.YoloEncryptModelEx(0, 0, "models/yolov8n.olam", "models/yolov8n.olam", 0, 0, "your_password", 0, 0, "value", "value");cpp
var ola = com("OlaPlug.OlaSoft")
var ret = ola.YoloEncryptModelEx(0, 0, "models/yolov8n.olam", "models/yolov8n.olam", 0, 0, "your_password", 0, 0, "value", "value")vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ret = ola.YoloEncryptModelEx(0, 0, "models/yolov8n.olam", "models/yolov8n.olam", 0, 0, "your_password", 0, 0, "value", "value")text
.局部变量 ola, OLAPlug
ola.创建 ()
ret = ola.YoloEncryptModelEx(0, 0, “models/yolov8n.olam”, “models/yolov8n.olam”, 0, 0, “your_password”, 0, 0, “value”, “value”)aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var ret = ola.YoloEncryptModelEx(0, 0, "models/yolov8n.olam", "models/yolov8n.olam", 0, 0, "your_password", 0, 0, "value", "value");text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
整数 ret = ola.YoloEncryptModelEx(0, 0, "models/yolov8n.olam", "models/yolov8n.olam", 0, 0, "your_password", 0, 0, "value", "value")cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
int32_t ret = ola.YoloEncryptModelEx(0, 0, "models/yolov8n.olam", "models/yolov8n.olam", 0, 0, "your_password", 0, 0, "value", "value");原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
YoloEncryptModelEx(instance, 0, 0, "models/yolov8n.olam", "models/yolov8n.olam", 0, 0, "your_password", 0, 0, 0, 0);csharp
using System.Runtime.InteropServices;
using System.Text;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int YoloEncryptModelEx(long ola, long modelData, int modelSize, long ncnnParamData, int ncnnParamSize, long labelData, int labelSize, string password, int modelType, int inferenceType, long outPackageData, long outPackageSize);
long instance = CreateCOLAPlugInterFace();
YoloEncryptModelEx(instance, 0, 0, "models/yolov8n.olam", "models/yolov8n.olam", 0, 0, "your_password", 0, 0, 0, 0);python
from ctypes import CDLL, c_int, c_int64, create_string_buffer
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
ola.YoloEncryptModelEx(instance, 0, 0, "models/yolov8n.olam", "models/yolov8n.olam", 0, 0, "your_password", 0, 0, 0, 0)返回值
| 返回值 | 说明 |
|---|---|
1 | 成功。 |
0 | 失败。 |
注意事项
| 项目 | 说明 |
|---|---|
| 模块权限 | 需要插件已开通 YOLO 模块权限(Reg、Login的FeatureList中包含YOLO特性)。 |
| 包内 names 归一化为 UTF-8 存储 | 包内 names 归一化为 UTF-8 存储;labelData 编码规则见 类别名称表说明。 |
| 释放内存 | 插件分配的内存须调用 FreeMemoryPtr 释放。 |
